<template>
  <div class="app-container">

    <el-table v-loading="loading" :data="dealDtlList" @selection-change="handleSelectionChange" border stripe>
      <el-table-column type="index" width="55" align="center" />
      <el-table-column label="物品编号" align="center" prop="pno" />
      <el-table-column label="物品名称" align="center" prop="name" />
      <el-table-column label="处置申请人" align="center" prop="contacts" />
      <el-table-column label="处置申请单位" align="center" prop="deptName" />
      <el-table-column label="签收时间" align="center" prop="handTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.handTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="处置单编号" align="center" prop="taskNo">
        <template slot-scope="scope">
          <el-link type="primary" @click="handleInfo(scope.row)">{{scope.row.taskNo}}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleInfo(scope.row)"
            v-hasPermi="['oms:task:query']">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改处置明细对话框 -->
    <el-drawer :title="title" :visible.sync="open" size="75%" :before-close="close">
        <div class="mb20 ml20">
          <span style="font-size: 20px;">{{form.taskNo}}</span>
          <div class="fr mr10">
            <el-button type="primary" size="mini" v-if="form.status == '0'"  @click="handleUpdate(form)">编辑</el-button>
            <el-button  size="mini" @click="handleSend(form)" v-if="form.sendReStatus == '0' || !form.sendReStatus">下发</el-button>
          </div>
        </div>
        <el-card>
         <el-tabs v-model="activeName">
            <el-tab-pane label="申请详情" name="1">
              <el-card>
                <el-descriptions title="基本信息" :column="4" border>
                  <el-descriptions-item label="申请单位" :span="2">{{form.deptName}}</el-descriptions-item>
                  <el-descriptions-item label="申请人">{{form.name}}</el-descriptions-item>
                  <el-descriptions-item label="联系电话">{{form.tel}}</el-descriptions-item>
                  <el-descriptions-item v-if="form.delivery == '0'" label="联系地址" :span="4">{{form.address}}</el-descriptions-item>
                  <el-descriptions-item label="物流配送">
                    <dict-tag :options="dict.type.oms_out_delivery_type" :value="form.delivery" />
                  </el-descriptions-item>
                  <!-- <el-descriptions-item :label="form.delivery == '0'?'期望上门时间':'预计到货时间'">
                    <span>{{ parseTime(form.expectTime, '{y}-{m}-{d}') }}</span>
                  </el-descriptions-item> -->
                  <el-descriptions-item label="调用数量">{{form.properties}}</el-descriptions-item>
                  <!-- <el-descriptions-item label="是否拖车">{{form.isTrailer == '0'?'否':'是'}}</el-descriptions-item> -->
                  <el-descriptions-item label="调用仓库">{{form.storeName}}</el-descriptions-item>
                  <el-descriptions-item label="有无钥匙" v-if="form.carKey">{{form.carKey}}</el-descriptions-item>
                  <el-descriptions-item label="有无行驶证" v-if="form.driveLicen">{{form.driveLicen}}</el-descriptions-item>
                  <el-descriptions-item label="无" v-if="form.othreNone">{{form.othreNone}}</el-descriptions-item>
                  <el-descriptions-item label="是否取证">
                    <el-tag :type="form.evidence == '0'?'info':'success'">{{form.evidence == '0'?'否':'是'}}</el-tag>
                  </el-descriptions-item>
                  <el-descriptions-item label="调用原因" :span="4">{{form.dispatchRemark}}</el-descriptions-item>
                  <el-descriptions-item label="附件" :span="4">
                    <!-- <el-image v-if="form.oss && form.oss.length > 0"
                      style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransfer(form.oss,'one')" fit="scale-down"
                      :preview-src-list="ossTransfer(form.oss,'list')"></el-image> -->
                      <el-image v-if="form.oss && form.oss.length > 0" v-for="(pic,pindex) in form.oss"
                      style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                      :preview-src-list="ossTransfer(form.oss,'list')"></el-image>
                  </el-descriptions-item>
                </el-descriptions>
              </el-card>
              <el-card v-if="show" class="mt10">
                <el-descriptions title="下发信息" :column="3" border>
                  <el-descriptions-item label="存放位置" :span="3">
                    <el-radio-group v-model="sendTaskForm.storeId">
                      <el-radio-button v-for="item in storeOptions" :key="item.id" :label="item.id">
                        {{item.label}}
                      </el-radio-button>
                    </el-radio-group>
                  </el-descriptions-item>
                  <el-descriptions-item label="承运商" :span="3">
                    <el-radio-group v-model="sendTaskForm.carrierDeptId">
                      <el-radio-button v-for="item in carrierOptions" :key="item.deptId" :label="item.deptId">
                        {{item.carrierName}}
                      </el-radio-button>
                    </el-radio-group>
                  </el-descriptions-item>
                  <template>
                    <el-descriptions-item label="派遣车辆" :span="2">
                      <el-select v-model="sendTaskForm.carId">
                        <el-option v-for="item in carOptions" :key="item.id" :label="item.carNumber" :value="item.id"></el-option>
                      </el-select>
                    </el-descriptions-item>
                    <el-descriptions-item label="取件人" :span="1">
                      <el-select v-model="sendTaskForm.pickupId">
                        <el-option v-for="item in userOptions" :key="item.userId" :label="item.nickName" :value="item.userId"></el-option>
                      </el-select>
                    </el-descriptions-item>
                  </template>
                </el-descriptions>
                <div class="mt10 fr mb10">
                  <el-button type="primary" :loading="buttonLoading" @click="submitForm" size="mini">确 定</el-button>
                  <el-button @click="handleClose" size="mini">取 消</el-button>
                </div>
              </el-card>
              <handover-order :form="form" :handoverOptions="handoverOptions" v-if="handoverOptions == null || handoverOptions.length == 0"></handover-order>
            </el-tab-pane>
            <el-tab-pane label="物品清单" name="2">
              <el-table :data="form.items"  border stripe>
                <el-table-column type="index" width="55" align="center"></el-table-column>
                <el-table-column label="物品编号" align="left" prop="pno" width="260">
                  <template slot-scope="scope">
                    <span>{{scope.row.pno}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="物品名称" align="left" prop="name" width="200">
                  <template slot-scope="scope">
                    <span>{{scope.row.name}}</span>
                  </template>
                </el-table-column>
                <el-table-column label="数量" align="center" prop="nums" width="75">
                  <template slot-scope="scope">
                    <span>{{scope.row.nums}}</span>
                  </template>
                </el-table-column>
                <!-- <el-table-column label="箱号" align="center" prop="boxNo">
                  <template slot-scope="scope" v-if="scope.row.boxNo">
                    <el-tag>{{scope.row.boxNo}}</el-tag>
                  </template>
                </el-table-column> -->
                <el-table-column label="图片" align="left" prop="oss">
                  <template slot-scope="scope">
                      <el-image v-if="scope.row.oss && scope.row.oss.length > 0" v-for="(pic,pindex) in scope.row.oss"
                      style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                      :preview-src-list="ossTransfer(scope.row.oss,'list')"></el-image>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="交接信息" name="3" v-if="handoverOptions && handoverOptions.length > 0">
              <handover-order :form="form" :handoverOptions="handoverOptions" v-if="handoverOptions && handoverOptions.length > 0"></handover-order>
            </el-tab-pane>
            <el-tab-pane label="交接原件" name="4" v-if="handoverOssList && handoverOssList.length > 0">
              <el-image  v-for="(pic,pindex) in handoverOssList"
              style="width: 100%;" :src="ossTransfer(pic,'list')" fit="scale-down"
              :preview-src-list="ossTransfer(handoverOssList,'list')"></el-image>
            </el-tab-pane>
            <el-tab-pane label="配送信息" name="5" v-if="orderOptions">
               <el-tabs tab-position="left">
                  <el-tab-pane label="订单信息">
                    <el-descriptions title="基本信息" :column="3" border>
                      <el-descriptions-item label="订单编号">{{orderOptions.orderNo}}</el-descriptions-item>
                      <el-descriptions-item label="所属部门">{{orderOptions.deptName}}</el-descriptions-item>
                      <el-descriptions-item label="物品数量">{{orderOptions.nums}}</el-descriptions-item>
                      <el-descriptions-item label="客户名称" v-if="orderOptions.clientName">{{orderOptions.clientName}}</el-descriptions-item>
                      <el-descriptions-item label="联系人" v-if="orderOptions.clientContacts">{{orderOptions.clientContacts}}</el-descriptions-item>
                      <el-descriptions-item label="联系电话" v-if="orderOptions.clientTel">{{orderOptions.clientTel}}</el-descriptions-item>
                      <el-descriptions-item label="备注" :span="3">{{orderOptions.memo}}</el-descriptions-item>
                    </el-descriptions>
                    <el-descriptions title="寄收地址" :column="3" border style="margin-top: 15px;">
                      <el-descriptions-item label="寄件单位">{{orderOptions.sendAddr}}</el-descriptions-item>
                      <el-descriptions-item label="寄件联系人">{{orderOptions.sendContacts}}</el-descriptions-item>
                      <el-descriptions-item label="联系方式">{{orderOptions.sendTel}}</el-descriptions-item>
                      <el-descriptions-item label="寄件地址" :span="3">{{orderOptions.sendAddress}}</el-descriptions-item>
                      <el-descriptions-item label="收件单位">{{orderOptions.takeAddr}}</el-descriptions-item>
                      <el-descriptions-item label="收件联系人">{{orderOptions.takeContacts}}</el-descriptions-item>
                      <el-descriptions-item label="联系方式">{{orderOptions.takeTel}}</el-descriptions-item>
                      <el-descriptions-item label="收件地址" :span="3">{{orderOptions.takeAddress}}</el-descriptions-item>
                    </el-descriptions>
                    <el-card style="margin-top: 15px;">
                      <div slot="header" class="clearfix">
                        <span style="font-weight: bold;">物品清单</span>
                      </div>
                      <el-table :data="orderOptions.items">
                        <el-table-column label="编号" prop="pno" />
                        <el-table-column label="名称" prop="name" />
                        <el-table-column label="数量" prop="nums" />
                      </el-table>
                    </el-card>
                    <el-card v-if="form.buss == '1'">
                      <div slot="header" class="clearfix">
                        <span>车辆附件</span>
                      </div>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                          <div slot="header" class="clearfix">
                            <span>全车外观</span>
                          </div>
                      <!--    <template v-for="pics in orderOptions.carOss">
                            <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                             :preview-src-list="[pics.url]"/>
                          </template> -->
                          <!-- <el-image
                            style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.carOss,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.carOss,'list')"></el-image> -->
                            <el-image v-if="orderOptions.facadeOss && orderOptions.facadeOss.length > 0" v-for="(pic,pindex) in orderOptions.facadeOss"
                            style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                            :preview-src-list="ossTransfer(orderOptions.facadeOss,'list')"></el-image>
                        </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>车架号</span>
                        </div>
                    <!--    <template v-for="pics in orderOptions.carOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.carOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.carOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.carOss && orderOptions.carOss.length > 0" v-for="(pic,pindex) in orderOptions.carOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.carOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>交接现场</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.handoverOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.handoverOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.handoverOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.handoverOss && orderOptions.handoverOss.length > 0" v-for="(pic,pindex) in orderOptions.handoverOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.handoverOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%" v-if="orderOptions.loadOss && orderOptions.loadOss.length > 0">
                        <div slot="header" class="clearfix">
                          <span>45度装车</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.loadOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.loadOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.loadOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.loadOss && orderOptions.loadOss.length > 0" v-for="(pic,pindex) in orderOptions.loadOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.loadOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>外观瑕疵</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.loadOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.loadOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.loadOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.flawOss && orderOptions.flawOss.length > 0" v-for="(pic,pindex) in orderOptions.flawOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.flawOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>到达目的地</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.takeOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.takeOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.takeOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.takeOss && orderOptions.takeOss.length > 0" v-for="(pic,pindex) in orderOptions.takeOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.takeOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>卸车</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.unloadOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                       <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.unloadOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.unloadOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.unloadOss && orderOptions.unloadOss.length > 0" v-for="(pic,pindex) in orderOptions.unloadOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.unloadOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>其他</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.otherOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.otherOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.otherOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.otherOss && orderOptions.otherOss.length > 0" v-for="(pic,pindex) in orderOptions.otherOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.otherOss,'list')"></el-image>
                      </el-card>
                      <el-card class="fl mr10 mb10" style="width: 32%">
                        <div slot="header" class="clearfix">
                          <span>其他</span>
                        </div>
                        <!-- <template v-for="pics in orderOptions.otherOss">
                          <el-image :src="pics.url" style="width: 120px;height: 80px;margin-right: 10px;"
                           :preview-src-list="[pics.url]"/>
                        </template> -->
                        <!-- <el-image
                          style="width: 120px; height: 80px;margin-right: 10px;" :src="ossTransfer(orderOptions.otherOss,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.otherOss,'list')"></el-image> -->
                          <el-image v-if="orderOptions.otherTwoOss && orderOptions.otherTwoOss.length > 0" v-for="(pic,pindex) in orderOptions.otherTwoOss"
                          style="width: 120px; height: 60px;margin-right: 5px;" :src="ossTransferThumbnail(pic,'one')" fit="scale-down"
                          :preview-src-list="ossTransfer(orderOptions.otherTwoOss,'list')"></el-image>
                      </el-card>
                    </el-card>
                  </el-tab-pane>
                  <el-tab-pane label="运单信息" v-if="orderOptions.wayItems && orderOptions.wayItems.length > 0">
                    <template v-for="item in orderOptions.wayItems">
                      <el-steps :active="item.status == 2?0:(item.status == 3?1:(item.status == 5?2:3))" align-center process-status="finish" finish-status="success" simple style="margin-bottom: 10px;">
                        <el-step title="发车"></el-step>
                        <el-step title="到达"></el-step>
                        <el-step title="签收"></el-step>
                        <el-step title="完成"></el-step>
                      </el-steps>
                      <el-tabs v-model="wayName">
                        <el-tab-pane label="基本信息" name="1">
                          <el-descriptions :column="3" border>
                            <el-descriptions-item label="运单编号">{{item.waybillNo}}</el-descriptions-item>
                            <el-descriptions-item label="线路">{{item.lineName}}</el-descriptions-item>
                            <el-descriptions-item label="车次">{{item.scheduleName}}</el-descriptions-item>
                            <el-descriptions-item label="车牌号">{{item.carNumber}}</el-descriptions-item>
                            <el-descriptions-item label="司机" :span="2">{{item.driverName}}</el-descriptions-item>
                            <el-descriptions-item label="物品数量">{{item.nums}}</el-descriptions-item>
                          </el-descriptions>
                        </el-tab-pane>
                        <el-tab-pane label="物品清单" name="2">
                          <el-card>
                            <el-table :data="item.items">
                              <el-table-column label="编号" prop="pno" />
                              <el-table-column label="名称" prop="name" />
                              <el-table-column label="数量" prop="nums" />
                            </el-table>
                          </el-card>

                        </el-tab-pane>
                        <el-tab-pane label="日志跟踪" name="3">
                          <el-card>
                            <el-table :data="item.logItems">
                              <el-table-column label="操作人" prop="operator" />
                              <el-table-column label="节点名称">
                                <template slot-scope="scope">
                                  <dict-tag :options="dict.type.tms_track_log_type" :value="scope.row.type" />
                                </template>
                              </el-table-column>
                              <el-table-column label="操作时间" prop="createTime"></el-table-column>
                              <el-table-column label="备注" prop="memeo" />
                            </el-table>
                          </el-card>
                        </el-tab-pane>
                      </el-tabs>
                    </template>
                  </el-tab-pane>
                </el-tabs>
            </el-tab-pane>
            <el-tab-pane label="挑拣任务" name="6" v-if="putTaskOptions && putTaskOptions.length > 0">
              <template v-for="item in putTaskOptions">
                <el-card style="margin-bottom: 15px;">
                  <!-- <el-button v-if="form.type == '2'" class="fr mb10" type="primary" size="mini" @click="handlePick(item)">挑拣</el-button> -->
                  <el-descriptions :column="3" border>
                    <el-descriptions-item label="任务编号">{{item.pickNo}}</el-descriptions-item>
                    <el-descriptions-item label="挑拣员">{{item.nickName}}</el-descriptions-item>
                    <el-descriptions-item label="状态">
                      <dict-tag :options="dict.type.wms_pick_task_status" :value="item.status" />
                    </el-descriptions-item>
                  </el-descriptions>
                  <el-card style="margin-top: 15px;" shadow="never">
                    <div slot="header" class="clearfix">
                      <span>物品清单</span>
                    </div>
                    <el-table :data="item.items">
                      <el-table-column label="编号" prop="pno" />
                      <el-table-column label="名称" prop="name" />
                      <el-table-column label="数量" prop="nums" />
                      <el-table-column label="状态" prop="nums">
                        <template slot-scope="scope">
                          <dict-tag :options="dict.type.wms_pick_task_status" :value="scope.row.status" />
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-card>
                </el-card>
              </template>
            </el-tab-pane>
            <el-tab-pane label="操作日志" name="7">
              <el-table :data="logOptions" border stripe>
                <el-table-column label="序号" type="index" width="50" align="center"/>
                <el-table-column label="操作时间" align="left" prop="logTime" width="180"/>
                <el-table-column label="操作人" align="left" prop="operator" width="200"/>
                <el-table-column label="操作内容" align="left" prop="content" />
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </el-card>
    </el-drawer>
  </div>
</template>

<script>
  import {
    listDealDtl,
    warnDealDtl,
    getDealDtl,
    delDealDtl,
    addDealDtl,
    updateDealDtl
  } from "@/api/wms/dealDtl";
  import {
    listTaskDtl,
    getTaskDtl,
    delTaskDtl,
    addTaskDtl,
    updateTaskDtl
  } from "@/api/oms/taskDtl";
  import { listTask,getTask,getStatisticsTask,updateTask } from "@/api/oms/task";
  import {listHandover,listHandoverInfo} from '@/api/wms/handover'
  import {listOss} from '@/api/system/oss'
  import {getOrderTask} from '@/api/tms/order';
  import {getPickTask} from '@/api/wms/pick'
  import {listOperatorLog} from "@/api/oms/operatorLog"
  export default {
    name: "DealDtl",
    dicts: ['wms_deal_status', 'wms_deal_type', 'sys_del_flag'],
    data() {
      return {
        // 按钮loading
        buttonLoading: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 处置明细表格数据
        dealDtlList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 状态时间范围
        daterangeCreateTime: [],
        // 状态时间范围
        daterangeUpdateTime: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          dealId: undefined,
          pno: undefined,
          name: undefined,
          dealType: undefined,
          status: undefined,
          createTime: undefined,
          createBy: undefined,
          updateTime: undefined,
          updateBy: undefined,
          delFlag: undefined
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          dealId: [{
            required: true,
            message: "处置记录ID不能为空",
            trigger: "blur"
          }],
          pno: [{
            required: true,
            message: "物品编号不能为空",
            trigger: "blur"
          }],
          name: [{
            required: true,
            message: "物品名称不能为空",
            trigger: "blur"
          }],
          nums: [{
            required: true,
            message: "数量不能为空",
            trigger: "blur"
          }],
          dealType: [{
            required: true,
            message: "处置方式不能为空",
            trigger: "change"
          }],
          pics: [{
            required: true,
            message: "图片附件不能为空",
            trigger: "blur"
          }],
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询处置明细列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
          this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
          this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
        }
        if (null != this.daterangeUpdateTime && '' != this.daterangeUpdateTime) {
          this.queryParams.params["beginUpdateTime"] = this.daterangeUpdateTime[0];
          this.queryParams.params["endUpdateTime"] = this.daterangeUpdateTime[1];
        }
        warnDealDtl(this.queryParams).then(response => {
          this.dealDtlList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      getHandoverOss(objid){
        listOss({'objid':objid,'buss':'handoverDtl'}).then(response=>{
          console.info('getHandoverOss======>',response)
          this.handoverOssList = response.rows;
        })
      },
      /** 查询交接信息 */
      getHandover(id){
        listHandoverInfo({'objid':id}).then(response=>{
          this.handoverOptions = response.data;
        })
      },
      /** 查询订单信息 */
      getOrderInfo(id){
        getOrderTask(id).then(response=>{
          this.orderOptions = response.data;
        })
      },
      /** 查询上架信息 */
      getPutTaskInfo(id){
        getPickTask(id).then(response=>{
          this.putTaskOptions = response.data;
        })
      },
      /** 查询日志 */
      getLogs(id){
        listOperatorLog({"objid":id}).then(response=>{
          this.logOptions = response.rows;
        })
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          dealId: undefined,
          pno: undefined,
          name: undefined,
          nums: undefined,
          dealType: undefined,
          pics: undefined,
          status: undefined,
          createTime: undefined,
          createBy: undefined,
          updateTime: undefined,
          updateBy: undefined,
          delFlag: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.daterangeCreateTime = [];
        this.daterangeUpdateTime = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加处置明细";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.loading = true;
        this.reset();
        const id = row.id || this.ids
        getDealDtl(id).then(response => {
          this.loading = false;
          this.form = response.data;
          this.open = true;
          this.title = "修改处置明细";
        });
      },
      //查看详情
      handleInfo(row){
        getTask(row.taskId).then(response=>{
          this.form = response.data;
          this.open = true;
          this.title = '处置申请详情';
          this.activeName = '1';
          //交接明细
          this.getHandover(row.taskId);
          this.getOrderInfo(row.taskId);
          this.getPutTaskInfo(row.taskId);
          this.getLogs(row.taskId);
          this.getHandoverOss(row.taskId);
        })
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            this.buttonLoading = true;
            if (this.form.id != null) {
              updateDealDtl(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }).finally(() => {
                this.buttonLoading = false;
              });
            } else {
              addDealDtl(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }).finally(() => {
                this.buttonLoading = false;
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除处置明细编号为"' + ids + '"的数据项？').then(() => {
          this.loading = true;
          return delDealDtl(ids);
        }).then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).finally(() => {
          this.loading = false;
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('wms/dealDtl/export', {
          ...this.queryParams
        }, `dealDtl_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>
